package com.cy.sc.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <br>@class: CloudClientController
 * <br>@description: 远程配置文件属性获取演示
 * <br>@author: cy
 * <br>@date: 2020-04-06 14:20:21
 * <br>@version: 1.0
 * <br>
 * <br>@since: (版本) 作者 时间 注释
 */
@RestController
@RequestMapping("/config")
@RefreshScope
public class CloudClientController {
    //远程 yml 中的属性映射,能获取到是因为，bootstrap.yml配置中设置了uri: http://localhost:7000
    //config-server去读取git时候会拿到信息，当config-client连接过来时候，会将信息传递
    @Value("${server.port}")
    private String port;
    @Value("${spring.application.name}")
    private String applicationName;
    @Value("${info.remark}")
    private String remark;

    @RequestMapping("/get")
    public String getConfigByServer(){
        return "获取信息如下:\t"+this.port+"\t"+this.applicationName+"\t"+this.remark;
    }
}
